import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class C1_12_5 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String find = br.readLine();
        String[] strs = br.readLine().split(" ");
        int count = 0;
        boolean flag = false;
        int length = 0;
        for (int i = 0; i < strs.length; i++) {
            if (strs[i].equalsIgnoreCase(find)) {
                count++;
            } else {
                if (count != 0) {
                    flag = true;
                }
                if (!flag) {
                    length += strs[i].length() + 1;
                }
            }
        }
        if(count == 0){
            System.out.println("-1");
        }else{
            System.out.println(count+" "+length);
        }
    }
}
